package common.server.exception;

import common.server.respcode.RespCode;
import common.server.respcode.RespCodeService;

/**
 * 基础异常
 * 
 * @author Administrator
 * @version [版本号, 2017/11/21 0021]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
public class BaseException extends RuntimeException {

	/**
	 * 
	 */
	private RespCode respCode;

	public BaseException(String message) {
		this(RespCodeService.COMM_ERROR,message);
	}

	public BaseException(String message, Throwable e) {
		this(RespCodeService.COMM_ERROR,message,e);
	}

	public BaseException(RespCode respCode) {
		this(RespCodeService.COMM_ERROR,"code:" + respCode.getCode() + ",desc:" + respCode.getDesc());
	}

	public BaseException(RespCode respCode, Throwable e) {
		this(RespCodeService.COMM_ERROR,"code:" + respCode.getCode() + ",desc:" + respCode.getDesc(),e);
	}

	public BaseException(RespCode respCode, String message) {
		super(message);
		this.respCode = respCode;
	}

	public BaseException(RespCode respCode, String message, Throwable e) {
		super(message,e);
		this.respCode = respCode;
	}



	public RespCode getRespCode() {
		return respCode;
	}

	public void setRespCode(RespCode respCode) {
		this.respCode = respCode;
	}

    @Override
    public String toString() {
        return "HljBaseException{" +
                "respCode=" + respCode +
                '}';
    }

    public boolean isRetCode() {
		return null != respCode;
	}
}
